<?php

/******************************************************************************
 *
 *	PROJECT: Flynax Classifieds Software
 *	VERSION: 4.0.1
 *	LISENSE: FL87MPRYOA0R - http://www.flynax.com/license-agreement.html
 *	PRODUCT: Auto Classifieds
 *	DOMAIN: www.siyaradiali.com
 *	FILE: RSS_FEED.INC.PHP
 *
 *	This script is a commercial software and any kind of using it must be 
 *	coordinate with Flynax Owners Team and be agree to Flynax License Agreement
 *
 *	This block may not be removed from this file or any other files with out 
 *	permission of Flynax respective owners.
 *
 *	Copyrights Flynax Classifieds Software | 2012
 *	http://www.flynax.com/
 *
 ******************************************************************************/

/* utf8 library functions */
function loadUTF8functions()
{
	$names = func_get_args();
	if ( empty($names) )
	{
		return false;
	}
	foreach ( $names as $name )
	{
		if (file_exists( RL_LIBS . 'utf8' . RL_DS . 'utils' . RL_DS . $name . '.php' ))
		{
			require_once( RL_LIBS . 'utf8' . RL_DS . 'utils' . RL_DS . $name . '.php' );
		}
	}
}
/* register */
$rlSmarty -> register_function('str2path', array( 'rlSmarty', 'str2path' ));
$rlSmarty -> register_function('rlHook', array( 'rlHook', 'load' ));

$languages = $rlLang -> getLanguagesList();
$rlLang -> modifyLanguagesList( $languages );

$reefless -> loadClass( 'Valid' );
$reefless -> loadClass( 'Categories' );
$reefless -> loadClass( 'Listings' );
$reefless -> loadClass( 'Common' );

$site_name = str_replace('&', '&amp;', $lang['pages+title+home']);
$rlSmarty -> assign('site_name', $site_name);

$id = (int)$_GET['id'];

if ( !empty($id) )
{
	/* get category info */
	$category = $rlCategories -> getCategory( $id );
	if ( empty($category) )
	{
		die();
	}
	$rlSmarty -> assign_by_ref('category', $category);
	
	$rss = array(
		'title' => $category['name'],
		'path' => $category['Path'],
		'id' => $category['ID']
	);
	$rlSmarty -> assign_by_ref( 'rss', $rss );
	
	/* get listings */
	$listings = $rlListings -> getListings( $category['ID'], false, 'ASC', $pInfo['current'], $config['listings_per_rss'] );
}
elseif ( isset($_GET['news']) )
{
	$reefless -> loadClass( 'News' );
	
	$news = $rlNews -> get( false, true, $pInfo['current'] );
	$rlSmarty -> assign_by_ref( 'news', $news );
	
	$rss = array(
		'title' => $lang['pages+name+'.$pages['news']],
		'description' => $lang['pages+meta_description+'.$pages['news']] ? $lang['pages+meta_description+'.$pages['news']] : $lang['pages+title+'.$pages['news']],
		'path' => $pages['news']
	);
	$rlSmarty -> assign_by_ref( 'rss', $rss );
}
else
{
	/* get recently added listings */
	$rss = array(
		'title' => $lang['pages+title+listings'] .' | '. $site_name,
		'description' => $lang['pages+meta_description+listings']
	);
	$rlSmarty -> assign_by_ref( 'rss', $rss );

	$listings = $rlListings -> getRecentlyAdded(0, $config['listings_per_rss']);
}
$rlSmarty -> assign_by_ref( 'listings', $listings );

header('Content-Type: text/xml');
